<?php

function neogeo_admin_city_main(){
global $XoopsTpl; 
xoops_cp_header();
	
	$XoopsTpl->display('db:neogeo_admin_mainmenu.html');	
	$regionH = & xoops_getmodulehandler("region",'neogeo');
	$cityH = & xoops_getmodulehandler("city",'neogeo');	
	$countryH = & xoops_getmodulehandler("country",'neogeo');	
	$cityitems = $cityH->getObjects();
	$XoopsTpl->assign("cityitems",$cityitems);
	$cityO = $cityH->create();
	$regions = $regionH->getObjects();
	$cityO->regions=array();
	$countries = $countryH->getObjects(null,1);
	foreach ($regions as $regionO){
	 $regionO->country = & $countries[$regionO->getVar('countryid')];
	 	 $cityO->regions[] = $regionO;
	}
	$XoopsTpl->assign_by_ref("cityO",$cityO);
	$XoopsTpl->display('db:neogeo_admin_city_main.html');

xoops_cp_footer();	
}
function neogeo_admin_city_create(){
global $XoopsTpl;    
xoops_cp_header(); 
$XoopsTpl->display('db:neogeo_admin_mainmenu.html');	
$XoopsTpl->display('db:neogeo_admin_city_create.html');
xoops_cp_footer(); 
}
function neogeo_admin_city_create_ok(){
$cityH = & xoops_getmodulehandler("city",'neogeo');
	 $cityO = $cityH->create();

	 $cityO->setFormVars($_POST,'city_');
	 $_SESSION['neogeo']['regid'] = $cityO->getVar('regid');
	 $cityH->insert($cityO);
	 redirect_header('index.php?type=city');
}
function neogeo_admin_city_edit(){
global $XoopsTpl;    
$cityH = & xoops_getmodulehandler("city",'neogeo');
$regionH = & xoops_getmodulehandler("region",'neogeo');
$countryH = & xoops_getmodulehandler("country",'neogeo');
$cityO = $cityH->get($_GET['id']);
$regions = $regionH->getObjects();
	$cityO->regions=array();
	$countries = $countryH->getObjects(null,1);
	foreach ($regions as $regionO){
	 $regionO->country = & $countries[$regionO->getVar('countryid')];
	 	 $cityO->regions[] = $regionO;
	}
	
	$XoopsTpl->assign_by_ref("cityO",$cityO);
	xoops_cp_header(); 
$XoopsTpl->display('db:neogeo_admin_mainmenu.html');	
$XoopsTpl->display('db:neogeo_admin_city_edit.html');
xoops_cp_footer(); 
}
function neogeo_admin_city_edit_ok(){
$cityH = & xoops_getmodulehandler("city",'neogeo');
	 $cityO = $cityH->get($_GET['id']);
	 $cityO->setFormVars($_POST,'city_');
	 $cityH->insert($cityO);
	 redirect_header('index.php?type=city');
}
function neogeo_admin_city_delete_ok(){
$cityH = & xoops_getmodulehandler("city",'neogeo');
	$cityO = $cityH->get($_GET['id']);
#	 $regionO->setFormVars($_POST,'region_');
	 $cityH->delete($cityO);
	 redirect_header('index.php?type=city');
}

?>